#coding:utf-8
import pyodbc
connection = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=PACS70D;UID=sa;PWD=sa')
cur=connection.cursor()
cur.execute("""
               select PatientID, Name
               from T_PPatient
            """)
i=0
for row in cur:
	i+=1
	print 'PatientID:',row.PatientID,'\t','Name:',row.Name
print 'T_PPatient count:  ',i

cur.execute("""
               select PatientID, Modality
               from T_PStudy 
            """)
i=0
for row in cur:
	i+=1
	print 'PatientID:',row.PatientID,'\t','Modality:',row.Modality
print 'T_PStudy  count:  ',i

cur.execute("""
               select PatientID,PatientName
               from T_NOFITSTUDY  
            """)
i=0
for row in cur:
	i+=1
	print 'PatientID:',row.PatientID,'\t','PatientName:',row.PatientName
print 'T_NOFITSTUDY  count:  ',i
raw_input(u'请按回车键结束'.encode('gbk'))